package com.uade.magicCompany.controler;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.uade.magicCompany.controler.utitilities.ActionConstants;
import com.uade.magicCompany.model.RapidPass;
import com.uade.magicCompany.services.GestionRapidPassImpl;
import com.uade.magicCompany.services.GestionRapidpass;

public class ConfirmarRapidPassAction extends ActionSupport{
	private String[] rapids;
	private List<RapidPass> passesResponse;
	
	
	@Override
	public String execute(){
		GestionRapidpass servicio= new GestionRapidPassImpl();
		String idEntrada=(String)ActionContext.getContext().getSession().get(ActionConstants.USER_LOGGED);
		passesResponse=servicio.confirmarCombinacion(getIds(), Long.valueOf(idEntrada));

		return SUCCESS;

	}
	
	
	
	public void validate()
	   {
	      if (rapids == null  || rapids.length!=3)
	      {
	         addFieldError("rapids","Se tienen que marcar 3 rapidPasses");
	      }

	   }
	
	private List<Long> getIds(){
		List<Long> ids= new ArrayList<Long>();
		for (int i=0;i<rapids.length;i++){
			ids.add(Long.valueOf(rapids[i]));
		}
		
		return ids;
	}



	public String[] getRapids() {
		return rapids;
	}



	public void setRapids(String[] rapids) {
		this.rapids = rapids;
	}



	public List<RapidPass> getPassesResponse() {
		return passesResponse;
	}



	public void setPassesResponse(List<RapidPass> passesResponse) {
		this.passesResponse = passesResponse;
	}
	
	
	

}
